package com.example.administrator.myapplication.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.bean.Weather;

import java.util.List;

/**
 * Created by Administrator on 2020/12/17.
 */

public class MyAdapter extends BaseAdapter{
    private Context context;
    private List<Weather.ResultBean.FutureBean> futureBeen;

    public MyAdapter(Context context, List<Weather.ResultBean.FutureBean> futureBeen) {
        this.context = context;
        this.futureBeen = futureBeen;
    }

    @Override
    public int getCount() {
        return futureBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return futureBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView=View.inflate(context, R.layout.listview_item_layout,null);
        TextView textView1= (TextView) convertView.findViewById(R.id.textview1);
        TextView textView2= (TextView) convertView.findViewById(R.id.textview2);
        TextView textView3= (TextView) convertView.findViewById(R.id.textview3);
        TextView textView4= (TextView) convertView.findViewById(R.id.textview4);
        textView1.setText(futureBeen.get(position).getTemperature()+"");
        textView2.setText(futureBeen.get(position).getWeather()+"");
        textView3.setText(futureBeen.get(position).getWind()+"");
        textView4.setText(futureBeen.get(position).getDate()+"");
        return convertView;
    }
}
